package com.easy.component.component.toast;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.easy.component.R;

/**
 * 描述: {描述}
 * 作者:jack-song
 * 创建日期: 2017/11/2 10:17
 * 修改日期: 2017/11/2
 * 版本: {版本}
 */
public class EasyToast {
    public EasyToast() {
    }

    public static void showShort(Context context, int resId) {
        showToast(context,context.getString(resId),Toast.LENGTH_SHORT);
    }

    public static void showShort(Context context, String message) {
        showToast(context,message,Toast.LENGTH_SHORT);
    }

    public static void showLong(Context context, int resId) {
        showToast(context,context.getString(resId),Toast.LENGTH_LONG);
    }

    public static void showLong(Context context, String message) {
        showToast(context,message,Toast.LENGTH_LONG);
    }

    public static void showToast(Context context, CharSequence text,int duration) {
//        Toast.makeText(context, text+"", duration).show();
        View mToastView  = LayoutInflater.from(context).inflate(R.layout.easy_toast, null);
        TextView mMessageTextView = (TextView) mToastView.findViewById(R.id.tv_easy_toast);
        mMessageTextView.setText(text);
        Toast mToast = new Toast(context);
        mToast.setDuration(duration);
        mToast.setView(mToastView);
        mToast.show();
    }
}
